package com.qf.first.controller;

import com.qf.first.dao.OrderMapper;
import com.qf.first.entity.Order;
import com.qf.first.entity.User;
import com.qf.first.pojo.vo.OrderVo;
import com.qf.first.pojo.vo.UserRole;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;

import java.util.List;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({"classpath:spring-context.xml","classpath:spring-mybatis.xml"})
@WebAppConfiguration
public class UserMapper {
    @Autowired
    private com.qf.first.dao.UserMapper userMapper;
    @Autowired
    private OrderMapper orderMapper;
    @Test
    public void testInsertUser(){
        User user = new User();
        user.setUserName("zs");
        user.setPassword("123");
        user.setSex("男");
        user.setPhone("1485996566");
        user.setImgUrl("null");
        int i = userMapper.insertUser(user);
        System.out.println(i);
    }
    @Test
    public void testGetUser(){
        User user = new User();
        user.setUserId(1006L);
        UserRole userRole = userMapper.selectUserById(user);
        System.out.println(userRole);
    }
    @Test
    public void testUpdateUser(){
        User user = new User();
        user.setPassword("333");
        user.setUserId(1006L);
        int i = userMapper.updateUser(user);
        System.out.println(i);
    }
    @Test
    public void testSelectOrderByUserId(){
        Order order = new Order();
        order.setUserId(1007L);
        order.setStateId(102);
        List<OrderVo> orderVos = orderMapper.selectOrderByUserId(order);
        System.out.println(orderVos);
    }

    @Test
    public void testUpdate(){
        Order order = new Order();
        order.setOrderId(6L);
        order.setStateId(104);
        int i = orderMapper.updateOrder(order);
        System.out.println(i);
    }
}
